﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList<MyMainSite.Models.ProjectBuild>>" %>

<script type="text/javascript">

	function downloadFile(buildId) {

		window.location = "/projects/downloadbuild/?projectbuildId=" + buildId;
	}

</script>

<h2>Project Builds</h2>

<% if (this.Model.Count <= 0)
   {
	   %><p>Sorry, there are no builds for this project at this time.</p><%
   }
   else
   {
	   %>
	    <nav>
        <ul class="projects ui-widget ui-helper-clearfix">
	   <%
	   foreach (var build in this.Model.OrderByDescending(b => b.UploadDate).OrderByDescending(b => new Version(b.Version)))
	   {
			%>
				<li class="ui-state-default ui-corner-all" data-commentid="<%: build.ProjectBuildId %>" onclick="downloadFile(<%: build.ProjectBuildId %>);">
					<div class="title"><%: build.Name %></div>
					<p>Version: <%: build.Version %></p>
					<div class="section2">Upload Date: <%: build.UploadDate.ToShortDateString() %></div>
					<div class="section2">Size: <%: build.Size.GetDownloadSize() %></div>
				</li>
			<%
	   }
	   %>
        </ul>
	    </nav>
	   <%
   }
%>